﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using AppManage.Infrastructure.Entity;

namespace AppManage.Infrastructure.Repository
{
    public interface IRepository<TEntity, TPrimaryKey> where TEntity : class, IEntity<TPrimaryKey>
    {
        DbSet<TEntity> Table { get; }

        int Count();
        int Count(Expression<Func<TEntity, bool>> predicate);
        void Delete(TEntity entity);
        void Delete(TPrimaryKey id);
        TEntity FirstOrDefault(TPrimaryKey id);
        IQueryable<TEntity> GetAll();
        IQueryable<TEntity> GetAllIncluding(params Expression<Func<TEntity, object>>[] propertySelectors);
        List<TEntity> GetAllList();
        TPrimaryKey InsertAndGetId(TEntity entity);
        int Update(TEntity entity);
    }
}